#include <iostream>
#include "../UdpServer.hpp"
#include "Thread.hpp"
#include "ThreadPool.hpp"

using namespace std;

int main(int argc, char* argv[])
{
    if(argc != 2)
    {
        printf("use error! usage: [%s your_port]\n", argv[0]);
        return 1;
    }

    UdpServer server(stoi(argv[1]));

    using task = function<void()>;

    ThreadPool<task>* pool = ThreadPool<task>::CreateThreadPool();
    auto task_func = [&server]() {
        server.start();
    };

    ThreadModule::Thread thread("push_task_thread");
    thread.start([&pool, task_func]() {
        pool->enQueue(task_func);
        sleep(1);
    });

    pool->start();

    thread.join();
    


    // ThreadModule::Thread thread("server_thread");
    // thread.start([&server]() {
    //     server.start();
    // });
    //thread.join();

    return 0;
}
